<template>
  <div class="playlist">
    <div class="playlist-top">
      <div class="left">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-bofang1"></use>
        </svg>
        <div class="text">
          <div class="title">播放全部</div>
          <div class="number">（共{{ playlist.tracks.length }}首）</div>
        </div>
      </div>
      <div class="btn">+ 收藏（{{ playlist.subscribedCount }}）</div>
    </div>
    <div class="list">
      <div
        class="playItem"
        v-for="(item, i) in playlist.tracks"
        :key="i"
        @click="setPlayIndex(i)"
      >
        <div class="left">
          <div class="index">{{ i + 1 }}</div>
          <div class="content">
            <div class="title">{{ item.name }}</div>
            <div class="author">
              <span
                class="tag"
                v-if="playlist.tags && playlist.tags.length > 0"
                >{{ playlist.tags[0] }}</span
              >
              <span class="name">{{ item.al.name }}</span>
            </div>
          </div>
        </div>
        <div class="right">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-bofang2"></use>
          </svg>
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-liebiao-dian"></use>
          </svg>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  name: "playList",
  components: {},
  props: ["playlist"],
  methods: {
    ...mapMutations(["setPlayIndex"]),
  },
};
</script>
<style lang="less" scoped>
.playlist {
  width: 7.5rem;
  padding: 0 0.4rem;
  background-color: #fff;
  border-top-left-radius: 0.3rem;
  border-top-right-radius: 0.3rem;
  margin-top: 0.4rem;
  .playlist-top {
    display: flex;
    justify-content: space-between;
    height: 0.8rem;
    align-items: center;
    .left {
      display: flex;
      align-items: center;
      .icon {
        width: 0.4rem;
        height: 0.4rem;
      }
      .title {
        font-size: 0.34rem;
        margin-left: 0.3rem;
      }
      .number {
        font-size: 0.24rem;
        color: #666;
      }
      .text {
        display: flex;
        align-items: center;
      }
    }
    .btn {
      font-size: 0.24rem;
      color: #fff;
      background: orangered;
      height: 0.6rem;
      line-height: 0.4rem;
      padding: 0.1rem;
      border-radius: 0.4rem;
    }
  }
  .list {
    .playItem {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 1rem;
      margin: 0.2rem;
      .left {
        display: flex;
        align-items: center;
        color: #666;
        flex: 1;
        .index {
          width: 0.6rem;
        }
        .title {
          font-size: 0.3rem;
          color: #000;
          margin-bottom: 0.1rem;
          overflow: hidden;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
        .author {
          display: flex;
          height: 0.4rem;
        }
        .tag {
          font-size: 0.2rem;
          color: orangered;
          border: 1px solid orangered;
          border-radius: 0.1rem;
          margin-right: 0.1rem;
          width: 0.8rem;
          text-align: center;
        }
        .name {
          overflow: hidden;
        }
      }
      .right {
        .icon {
          margin-left: 0.1rem;
          width: 0.5rem;
          height: 0.5rem;
          fill: #666;
        }
      }
    }
  }
}
</style>